<?php
/*
 * @Author: your name
 * @Date: 2019-12-19 15:33:29
 * @LastEditTime : 2020-01-03 14:29:55
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /ahsmp_3/application/common/service/ServerSocketMessageHistory.php
 */

namespace app\common\service;


class ServerSocketMessageHistory extends Base 
{

    /**
     * @name: 列表
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2019-12-20 09:58:47
     */
    function list ($userId, $limit)
    {
        $return = db('ServerSocketMessageHistory')
            ->field('id,host_id,module,user_id,description,content_md5,err_id,err_msg,ctime')
            ->where('err_id', '>', 0)->where('ignore', 0)->where('user_id', $userId)
            ->order('ctime desc')
            ->paginate($limit)->toArray();

        return $return;
    }

    /**
     * @name: 错误条数
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-01-03 14:09:20
     */
    function errCount($userId)
    {
        $return = db('ServerSocketMessageHistory')->where('user_id', $userId)->where('err_id', '>', 0)->where('ignore', 0)->count();

        return $return;
    }

    /**
     * @name: 忽略
     * @Param: 
     * @Description: 
     * @Author: foo
     * @Date: 2020-01-03 14:25:47
     */
    function ignore ($id_s)
    {
        db('ServerSocketMessageHistory')->whereIn('id', $id_s)->update(['ignore' => 1]);
    }
}